/*
ID:luongho3
LANG:C++
TASK:beads
*/
#include <iostream>
#include <fstream>
#define WHITE 'w'
#define RED 'r'
#define BLUE 'b'
using namespace std;
int len;
string beads;
ifstream fin("beads.in");
ofstream fout("beads.out");
void read() {
     fin>>len>>beads;     
}
int prev(int pos,int len) {
    int result = (pos-1);
    if (result < 0) result = len-1;
    return result;
}
int next(int pos,int len) {
    int result = pos+1;
    if (result>=len) result = 0;
    return result;   
}
int move(int pos,int len, int direction) {
    if (direction == 0) {
       return next(pos, len);
    }
    else {
         return prev(pos,len);
    }
}
int countBead(int pos,int direction, int len) {
    char flag = beads[pos];
    int counter=move(pos,len,direction);
    int result = 1;
    do {
        if (beads[counter] == WHITE) {
           ++result;
           counter = move(counter,len,direction);
        }
        else {
             if (flag == WHITE) {
                ++result;
                flag = beads[counter];
                counter = move(counter,len,direction);
                
             }
             else if (flag == beads[counter]) {
                  ++result;
                  counter = move(counter,len,direction);
             }
             else break;
        }
    } while (counter!=pos);
    return result;
}
int tryAt(int pos) {
    int forward, backward;
    forward = countBead(pos,0,len);
    backward = countBead(prev(pos,len),1,len);
    if (forward + backward  > len) {
       return len;
    }  
    else return (forward + backward);
}
int solve() {
    int i;
    int result = 1;
    for (i=0;i<len;++i) {
        int temp = tryAt(i);
        if (temp>result)
           result = temp;
    }   
    return result;
}
int main() {
    read();
    int result = solve();
    fout << result <<"\n";
    return 0;
}
